<?php
class model_MessageModel {
    private $id;
    private $text;
    private $kto;
    private $komu;
    private $date;
    private $isread;

    public function  __construct($row) {
        $this->setId($row['id'])
                ->setText($row['text'])
                ->setKto($row['kto'])
                ->setKomu($row['komu'])
                ->setDate($row['date'])
                ->setIsread($row['isread']);
    }

    public function cutString($string, $maxlen){
        $len = (mb_strlen($string)>$maxlen)
                ? mb_strripos(mb_substr($string, 0, $maxlen), ' ')
                :$maxlen;
        $cutStr = mb_substr($string, 0, $len);
        return (mb_strlen($string)>$maxlen)
        ? ''.$cutStr.'...'
        : ''.$cutStr.'';
    }

    public  function setId($id) {
        $this->id = $id;
        return $this;
    }

    public  function getId() {
        return $this->id;
    }

    public function getText() {
        return $this->text;
    }

    public function setText($text) {
        $this->text = $text;
        return $this;
    }

    public function getKto() {
        return $this->kto;
    }

    public function setKto($kto) {
        $this->kto = $kto;
        return $this;
    }

    public function getKomu() {
        return $this->komu;
    }

    public function setKomu($komu) {
        $this->komu = $komu;
        return $this;
    }

    public  function setDate($date) {
        $this->date = $date;
        return $this;
    }

    public  function getDate() {
        return $this->date;
    }

    public function getIsread() {
        return $this->isread;
    }

    public function setIsread($isread) {
        $this->isread = $isread;
        return $this;
    }
}